package com.avic.rong.adapter.show;

import android.content.Context;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.avic.rong.R;
import com.avic.rong.bean.show_bean.AchieveBean;

import java.util.List;

/**
 * Created by TSJ-2018-0492 on 2019/9/19.
 */

public class AchsupplyAdaptere extends RecyclerView.Adapter<AchsupplyAdaptere.AchsupplyViewHolder>{
    private Context context;

    private List<AchieveBean.SupplyListBean> supplyListBeans;

    public void setSupplyListBeans(List<AchieveBean.SupplyListBean> supplyListBeans) {
        this.supplyListBeans = supplyListBeans;
    }

    public AchsupplyAdaptere(Context context) {
        this.context = context;
    }

    @NonNull
    @Override
    public AchsupplyViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) {
        View view = LayoutInflater.from(context).inflate(R.layout.achieve_cnxy_item, viewGroup, false);
        return new AchsupplyViewHolder(view);

    }

    @Override
    public void onBindViewHolder(@NonNull AchsupplyViewHolder achsupplyViewHolder, int i) {
        if (supplyListBeans!=null) {
            AchieveBean.SupplyListBean supplyListBean = supplyListBeans.get(i);
            achsupplyViewHolder.achieve_cnxy_name.setText(supplyListBean.getSupplyTitle()+"");
            achsupplyViewHolder.achieve_cnxy_up.setText(supplyListBean.getCompanyName()+"");
            achsupplyViewHolder.achieve_cnxy_down.setText(supplyListBean.getCity()+supplyListBean.getAddress());
            achsupplyViewHolder.achieve_cnxy_price.setText("参考价格:"+supplyListBean.getPrice()+"");
        }
    }

    @Override
    public int getItemCount() {
        if (supplyListBeans!=null) {
            return supplyListBeans.size();
        }
        return 0;
    }

    public class AchsupplyViewHolder extends RecyclerView.ViewHolder {

        private final TextView achieve_cnxy_name;
        private final TextView achieve_cnxy_price;
        private final TextView achieve_cnxy_up;
        private final TextView achieve_cnxy_down;
        private final ImageView achieve_cnxy_image;

        public AchsupplyViewHolder(@NonNull View itemView) {
            super(itemView);
            achieve_cnxy_image = itemView.findViewById(R.id.achieve_cnxy_image);
            achieve_cnxy_down = itemView.findViewById(R.id.achieve_cnxy_down);
            achieve_cnxy_name = itemView.findViewById(R.id.achieve_cnxy_name);
            achieve_cnxy_price = itemView.findViewById(R.id.achieve_cnxy_price);
            achieve_cnxy_up = itemView.findViewById(R.id.achieve_cnxy_up);
        }
    }
}
